﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using FXnaEngine.Graphics;

using Microsoft.Xna.Framework.Graphics;




namespace FXnaEngine.Components
{
   public  class FMeshRendererComponent:FRendererComponent
    {


       public FMeshRendererComponent(FEntity parent)
           : base(parent)
       {


           

       }


       public FMeshRendererComponent(FEntity parent, FMesh mesh):base(parent)
       {
           this.mesh = mesh;


       }






       FMesh mesh;

       public FMesh Mesh
       {
           get { return mesh; }
           set { mesh = value; }
       }


      



       public override bool ExecuteMessage(IMessage message)
       {

           return true;




       }


       protected override void RenderCore(FGraphicsSystem graphics)
       {
           
           base.RenderCore(graphics);

           if (this.mesh!=null)
           {

           






               graphics.ShaderBasic.SetParameters(this.material, this.parentEntity.Transform.WorldMatrix);



               graphics.RenderWithEffect(mesh, graphics.ShaderBasic.BasicEffect);







              





               

           }





       }




    }
}
